package service;

import Man.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import pojo.User;

import java.io.IOException;
import java.io.InputStream;

public class userser {

public User login(String name,String pwd) throws IOException {

    String resource = "mybatis-config.xml";
    InputStream inputStream = Resources.getResourceAsStream(resource);
    SqlSessionFactory sqlSessionfactory = new SqlSessionFactoryBuilder().build(inputStream);

    SqlSession sqlSession=sqlSessionfactory.openSession();
    UserMapper userMapper=sqlSession.getMapper(UserMapper.class);
    User user=userMapper.selcet(name,pwd);

    sqlSession.close();

    return user;
    }
}
